/**
 *
 */
package com.googlecode.bip.entity;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;

/**
 * TODO
 * @author Claude CHOISNET
 *
 */
public class Administrator implements Serializable
{
    private static final long serialVersionUID = 1L;
    private int idadministrator;
    private String username;
    private String password;
    private Set<String> roles = new HashSet<String>();

    /**
     * Create a NOT initialized User
     */
    public Administrator()
    {
    }

    /**
     * Create a shadow copy of giving User
     *
     * @param o User to clone
     */
    public Administrator( final Administrator o )
    {
        this.idadministrator    = o.idadministrator;
        this.username           = o.username;
        this.password           = o.password;
        this.roles.clear();

        for(String role : o.roles) {
            this.roles.add( role );
            }
    }

    /**
     *
     * @param rSet
     * @return
     * @throws SQLException
     */
    public Administrator set( final ResultSet rSet ) throws SQLException
    {
        this.idadministrator   = rSet.getInt( "idadministrator" );
        this.username = rSet.getString( "username" );
        this.password = rSet.getString( "password" );
        this.roles.clear();
        this.roles.add( rSet.getString( "role_name" ) );

        return this;
    }

    /**
     * @return the idadministrator
     */
    public int getIdadministrator()
    {
        return idadministrator;
    }

    /**
     * @param idadministrator the idadministrator to set
     */
    public void protected_setIdadministrator( int idadministrator )
    {
        this.idadministrator = idadministrator;
    }

    /**
     * @return the username
     */
    public String getUsername()
    {
        return username;
    }

    /**
     * @param username the username to set
     */
    public void setUsername( String username )
    {
        this.username = username;
    }

    /**
     * @return the password
     */
    public String getPassword() // TODO: REMOVE THIS
    {
        return password;
    }

    /**
     * @param password the password to set
     */
    public void setPassword( String password )
    {
        this.password = password;
    }


}
